﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace FDEE.Model
{
    public class Footing4Cal1 : FootingBase
    {
        Dictionary<int, Dictionary<eDB, int>> _dicDB = new Dictionary<int, Dictionary<eDB, int>>();
        EFootingType _ePCType;
        int _pierHeight = 0;
        /// <summary>
        /// 矩形单层承台配筋参数设置
        /// </summary>
        /// <param name="typeName"></param>
        /// <param name="pierNumber"></param>
        /// <param name="subType"></param>
        /// <param name="Height"></param>
        /// <param name="Length"></param>
        /// <param name="Width"></param>
        /// <param name="dicDB"></param>
        public Footing4Cal1(EFootingType ePCType, string typeName, string pierNumber, eSubType subType, int Height, int Length, int Width, Dictionary<int, Dictionary<eDB, int>> dicDB)
            : base(ePCType, typeName, pierNumber, subType, Width, Length, Height)
        {
            _dicDB = dicDB;
            _ePCType = ePCType;
        }
        /// <summary>
        /// 配筋及混凝土体积计算
        /// </summary>
        public override void SetRebarList()
        {
            RebarList = new RebarCollection();
            int diaOfN1 = 28;
            int diaOfN2 = 28;
            int diaOfN3 = 16;
            int diaOfN4 = 16;
            int diaOfN5 = 16;
            int diaOfN6 = 32;
            int spaceN1 = 100, spaceN2 = 100, spaceN3 = 100, spaceN4 = 100, spaceN5 = 100, spaceN6 = 100;
            eDB N1 = eDB.DB28, N2 = eDB.DB28, N3 = eDB.DB16, N4 = eDB.DB16, N5 = eDB.DB16, N6;
            if (_dicDB.Count > 0)
            {
                N1 = _dicDB[1].Keys.ToList()[0];
                diaOfN1 = PublicEnumItems.GeteDBData(N1.ToString());
                spaceN1 = _dicDB[1].Values.ToList()[0];
            }
            if (_dicDB.Count > 1)
            {
                N2 = _dicDB[2].Keys.ToList()[0];
                diaOfN2 = PublicEnumItems.GeteDBData(N2.ToString());
                spaceN2 = _dicDB[2].Values.ToList()[0];
            }
            if (_dicDB.Count > 2)
            {
                N3 = _dicDB[3].Keys.ToList()[0];
                diaOfN3 = PublicEnumItems.GeteDBData(N3.ToString());
                spaceN3 = _dicDB[3].Values.ToList()[0];
            }
            if (_dicDB.Count > 3)
            {
                N4 = _dicDB[4].Keys.ToList()[0];
                diaOfN4 = PublicEnumItems.GeteDBData(N4.ToString());
                spaceN4 = _dicDB[4].Values.ToList()[0];
            }
            if (_dicDB.Count > 4)
            {
                N5 = _dicDB[5].Keys.ToList()[0];
                diaOfN5 = PublicEnumItems.GeteDBData(N5.ToString());
                spaceN5 = _dicDB[5].Values.ToList()[0];
            }
            if (_dicDB.Count > 5)
            {
                N6 = _dicDB[6].Keys.ToList()[0];
                diaOfN6 = PublicEnumItems.GeteDBData(N6.ToString());
                spaceN6 = _dicDB[6].Values.ToList()[0];
            }
            switch (_ePCType)
            {
                case EFootingType.FPE11:
                case EFootingType.FPE12:
                case EFootingType.FPE13:
                case EFootingType.FPE14:
                case EFootingType.FPE21A:
                case EFootingType.FPE21B:
                case EFootingType.FPE22:
                case EFootingType.FPE31:
                case EFootingType.FPE32:
                case EFootingType.FPTE2:
                    //N1      
                    RebarList.Add(new MIRebarRecord(1, 0, "", N1, Length, 75,
                    Height - 100 - 75 - 500 + 400, RebarArrangement.EqualArr(Width - 75 * 2, spaceN1), eShapeType.MI));

                    //N2 
                    RebarList.Add(new MIRebarRecord(2, 0, "", N2, Width, 75,
                           Height - 100 - diaOfN1 - 75 - 500 + 400, RebarArrangement.EqualArr(Length - 75 * 2, spaceN2), eShapeType.MI));
                    break;
                default:
                    //N1      
                    RebarList.Add(new MIRebarRecord(1, 0, "", N1, Length, 75,
                    Height - 100 - 75 - 500 + 400, RebarArrangement.EqualArr(Width - 75 * 2 - diaOfN1, spaceN1), eShapeType.MI));

                    //N2 
                    RebarList.Add(new MIRebarRecord(2, 0, "", N2, Width, 75,
                           Height - 100 - diaOfN1 - 75 - 500 + 400, RebarArrangement.EqualArr(Length - 75 * 2 - diaOfN2, spaceN2), eShapeType.MI));
                    break;
            }
            //N3
            RebarList.Add(new MIRebarRecord(3, 0, "", N3, Length, 75, 500,
                RebarArrangement.EqualArr(Width - 75 * 2, spaceN3), eShapeType.MI));

            //N4
            RebarList.Add(new MIRebarRecord(4, 0, "", N4, Width, 75, 500,
                RebarArrangement.EqualArr(Length - 75 * 2, spaceN4), eShapeType.MI));

            //N5
            int bb = (Length - 2 * (75 + diaOfN1 - 640)) / 2;
            int cc = bb - 640;
            //RebarList.Add(new MIRebarRecord(5, 1, "", N5, Width - 2 * diaOfN2, 75, bb, cc, 3, eShapeType.MI));
            //RebarList.Add(new MIRebarRecord(5, 2, "", N5, Width - 2 * diaOfN2, 75, bb, cc, 3, eShapeType.MI));
            if (_ePCType == EFootingType.FPTE3 || _ePCType == EFootingType.FPTE32 || _ePCType == EFootingType.FPTL2)
            {
                RebarList.Add(new MIRebarRecord(5, 1, "", N5, Width - 2 * diaOfN2, 75, bb, cc, 4, eShapeType.MI));
                RebarList.Add(new MIRebarRecord(5, 2, "", N5, Width - 2 * diaOfN2, 75, bb, cc, 4, eShapeType.MI));
            }
            else
            {
                RebarList.Add(new MIRebarRecord(5, 1, "", N5, Width - 2 * diaOfN2, 75, bb, cc, 3, eShapeType.MI));
                RebarList.Add(new MIRebarRecord(5, 2, "", N5, Width - 2 * diaOfN2, 75, bb, cc, 3, eShapeType.MI));
            }
            #region 起步钢筋
            //if (true)
            //{

            //    RebarList.Add(new MHXRebarRecord(6, 1, "", eDB.DB32, false, 15 * 2, eShapeType.MHXe));
            //    RebarList.Add(new MHXRebarRecord(6, 2, "", eDB.DB32, false, 12 * 2, eShapeType.MHXe));
            //    RebarList.Add(new MHXRebarRecord(6, 3, "", eDB.DB32, true, 10 * 2, eShapeType.MHXi));
            //    RebarList.Add(new MHXRebarRecord(6, 4, "", eDB.DB32, true, 26, eShapeType.MHXi));
            //    RebarList.Add(new MHXRebarRecord(6, 5, "", eDB.DB32, false, 4 * 2, eShapeType.MHXe));
            //}
            //else
            //{
            //    // 未完成
            //    throw new NotImplementedException();
            //}
            #endregion
        }


        public void SetRebarListStart()
        {
            var kk = MemberFactory.CreatMember(MemberFactory.FromFootingToColumn(_ePCType), SubType, 13728);
            var f = kk.RebarList;
        }
    }


    public class Footing4Cal2 : FootingBase
    {

        Dictionary<int, Dictionary<eDB, int>> _dicDB = new Dictionary<int, Dictionary<eDB, int>>();
        Dictionary<int, Dictionary<eDB, int>> _diConvert2DB = new Dictionary<int, Dictionary<eDB, int>>();
        EFootingType _ePCType;
        int _pierHeight = 0;//墩高
        /// <summary>
        /// 矩形双层承台
        /// </summary>
        /// <param name="typeName">承台类型</param>
        /// <param name="pierNumber">墩号</param>
        /// <param name="subType">高度分类</param>
        /// <param name="Height">高度</param>
        /// <param name="Length">长度</param>
        /// <param name="Width">宽度</param>
        /// <param name="dicDB">钢筋直径字典</param>
        /// <param name="diConvert2DB">1、2钢筋直筋直径字典</param>
        public Footing4Cal2(EFootingType ePCType, string typeName, string pierNumber, eSubType subType, int Height, int Length, int Width, Dictionary<int, Dictionary<eDB, int>> dicDB, Dictionary<int, Dictionary<eDB, int>> diConvert2DB)
            : base(ePCType, typeName, pierNumber, subType, Width, Length, Height)
        {
            _dicDB = dicDB;
            _diConvert2DB = diConvert2DB;
            _ePCType = ePCType;

        }

        public override void SetRebarList()
        {
            RebarList = new RebarCollection();
            int diaOfN1a = 28;
            int diaOfN2a = 28;
            int diaOfN1b = 28;
            int diaOfN2b = 28;
            int diaOfN3 = 16;
            int diaOfN4 = 16;
            int diaOfN5 = 32;
            int diaOfN6 = 32;
            int spaceN1 = 100, spaceN2 = 100, spaceN3 = 100, spaceN4 = 100, spaceN5 = 100, spaceN6 = 100, spaceN1b = 100, spaceN2b = 100;
            eDB N1 = eDB.DB28, N2 = eDB.DB28, N3 = eDB.DB16, N4 = eDB.DB16, N5 = eDB.DB32, N6 = eDB.DB32, N1b = eDB.DB28, N2b = eDB.DB28;
            if (_dicDB.Count > 0)
            {
                N1 = _dicDB[1].Keys.ToList()[0];
                diaOfN1a = PublicEnumItems.GeteDBData(N1.ToString());
                spaceN1 = _dicDB[1].Values.ToList()[0];
            }
            if (_dicDB.Count > 1)
            {
                N2 = _dicDB[2].Keys.ToList()[0];
                diaOfN2a = PublicEnumItems.GeteDBData(N2.ToString());
                spaceN2 = _dicDB[2].Values.ToList()[0];
            }
            if (_dicDB.Count > 2)
            {
                N3 = _dicDB[3].Keys.ToList()[0];
                diaOfN3 = PublicEnumItems.GeteDBData(N3.ToString());
                spaceN3 = _dicDB[3].Values.ToList()[0];
            }
            if (_dicDB.Count > 3)
            {
                N4 = _dicDB[4].Keys.ToList()[0];
                diaOfN4 = PublicEnumItems.GeteDBData(N4.ToString());
                spaceN4 = _dicDB[4].Values.ToList()[0];
            }
            if (_dicDB.Count > 4)
            {
                N5 = _dicDB[5].Keys.ToList()[0];
                diaOfN5 = PublicEnumItems.GeteDBData(N5.ToString());
                spaceN5 = _dicDB[5].Values.ToList()[0];
            }
            if (_dicDB.Count > 5)
            {
                N6 = _dicDB[6].Keys.ToList()[0];
                diaOfN6 = PublicEnumItems.GeteDBData(N6.ToString());
                spaceN6 = _dicDB[6].Values.ToList()[0];
            }
            switch (_ePCType)
            {

                case EFootingType.FPE11:
                case EFootingType.FPE12:
                case EFootingType.FPE13:
                case EFootingType.FPE14:
                case EFootingType.FPE21A:
                case EFootingType.FPE21B:
                case EFootingType.FPE22:
                case EFootingType.FPE31:
                case EFootingType.FPE32:
                case EFootingType.FPTE2:
                    if (_diConvert2DB.Count > 0)
                    {
                        //N1a      
                        RebarList.Add(new MIRebarRecord(1, 0, "A", N1, Length, 75,
                    Height - 100 - 75 - 500 + 400, RebarArrangement.EqualArr(Width - 75 * 2, spaceN1), eShapeType.MI));
                    }
                    else
                    {
                        RebarList.Add(new MIRebarRecord(1, 0, "", N1, Length, 75,
                                  Height - 100 - 75 - 500 + 400, RebarArrangement.EqualArr(Width - 75 * 2, spaceN1), eShapeType.MI));
                    }
                    //N1b      
                    if (_diConvert2DB.Count > 0)
                    {
                        N1b = _diConvert2DB[1].Keys.ToList()[0];
                        diaOfN1b = PublicEnumItems.GeteDBData(N1b.ToString());
                        spaceN1b = _diConvert2DB[1].Values.ToList()[0];
                        RebarList.Add(new MARebarRecord(1, 0, "B", N1b, Length - 2 * (75 + diaOfN1a), RebarArrangement.EqualArr(Width - 75 * 2, spaceN1b), eShapeType.MA));
                    }

                    //N2b 
                    if (_diConvert2DB.Count > 1)
                    {

                        //N2a 
                        RebarList.Add(new MIRebarRecord(2, 0, "A", N2, Width, 75,
                                  Height - 100 - diaOfN1a - 75 - 500 + 400, RebarArrangement.EqualArr(Length - 75 * 2, spaceN2), eShapeType.MI));

                        N2b = _diConvert2DB[2].Keys.ToList()[0];
                        diaOfN2b = PublicEnumItems.GeteDBData(N2b.ToString());
                        spaceN2b = _diConvert2DB[2].Values.ToList()[0];
                        RebarList.Add(new MARebarRecord(2, 0, "B", N2b, Width - 2 * (75 + diaOfN2a), RebarArrangement.EqualArr(Length - 75 * 2 - diaOfN2b * 2, spaceN2b), eShapeType.MA));
                    }
                    else
                    {

                        //N2a 
                        RebarList.Add(new MIRebarRecord(2, 0, "", N2, Width, 75,
                                  Height - 100 - diaOfN1a - 75 - 500 + 400, RebarArrangement.EqualArr(Length - 75 * 2, spaceN2), eShapeType.MI));
                    }
                    break;
                case EFootingType.FPTM2U:
       
                        RebarList.Add(new MIRebarRecord(1, 0, "", N1, Length, 75,
                                  Height - 100 - 75 - 500 + 400, RebarArrangement.EqualArr(Width - 75 * 2 - diaOfN1a, spaceN1) * 2, eShapeType.MI));
                   
                        //N2a 
                        RebarList.Add(new MIRebarRecord(2, 0, "", N2, Width, 75,
                                  Height - 100 - diaOfN1a - 75 - 500 + 400, RebarArrangement.EqualArr(Length - 75 * 2 - diaOfN2a, spaceN2)*2, eShapeType.MI));
                    
                    break;
      
                default:
                    if (_diConvert2DB.Count > 0)
                    {
                        //N1a      
                        RebarList.Add(new MIRebarRecord(1, 0, "A", N1, Length, 75,
                    Height - 100 - 75 - 500 + 400, RebarArrangement.EqualArr(Width - 75 * 2 - diaOfN1a, spaceN1), eShapeType.MI));
                    }
                    else
                    {
                        RebarList.Add(new MIRebarRecord(1, 0, "", N1, Length, 75,
                                  Height - 100 - 75 - 500 + 400, RebarArrangement.EqualArr(Width - 75 * 2 - diaOfN1a, spaceN1), eShapeType.MI));
                    }
                    //N1b      
                    if (_diConvert2DB.Count > 0)
                    {
                        N1b = _diConvert2DB[1].Keys.ToList()[0];
                        diaOfN1b = PublicEnumItems.GeteDBData(N1b.ToString());
                        spaceN1b = _diConvert2DB[1].Values.ToList()[0];
                        RebarList.Add(new MARebarRecord(1, 0, "B", N1b, Length - 2 * (75 + diaOfN1a), RebarArrangement.EqualArr(Width - 75 * 2 - diaOfN1b, spaceN1b), eShapeType.MA));
                    }

                    //N2b 
                    if (_diConvert2DB.Count > 1)
                    {

                        //N2a 
                        RebarList.Add(new MIRebarRecord(2, 0, "A", N2, Width, 75,
                                  Height - 100 - diaOfN1a - 75 - 500 + 400, RebarArrangement.EqualArr(Length - 75 * 2 - diaOfN2a, spaceN2), eShapeType.MI));

                        N2b = _diConvert2DB[2].Keys.ToList()[0];
                        diaOfN2b = PublicEnumItems.GeteDBData(N2b.ToString());
                        spaceN2b = _diConvert2DB[2].Values.ToList()[0];
                        RebarList.Add(new MARebarRecord(2, 0, "B", N2b, Width - 2 * (75 + diaOfN2a), RebarArrangement.EqualArr(Length - 75 * 2 - diaOfN2b * 2 - diaOfN2b, spaceN2b), eShapeType.MA));
                    }
                    else
                    {

                        //N2a 
                        RebarList.Add(new MIRebarRecord(2, 0, "", N2, Width, 75,
                                  Height - 100 - diaOfN1a - 75 - 500 + 400, RebarArrangement.EqualArr(Length - 75 * 2 - diaOfN2a, spaceN2), eShapeType.MI));
                    }
                    break;
            }

            //N3/N4
            RebarList.Add(new MIRebarRecord(3, 0, "", N3, Length, 75, 500,
                RebarArrangement.EqualArr(Width - 75 * 2, spaceN3), eShapeType.MI));

            //N4
            RebarList.Add(new MIRebarRecord(4, 0, "", N4, Width, 75, 500,
                RebarArrangement.EqualArr(Length - 75 * 2, spaceN4), eShapeType.MI));

            //N5
            int bb = (Length - 2 * (75 + diaOfN1a - 640)) / 2;
            int cc = bb - 640;

            RebarList.Add(new MIRebarRecord(5, 1, "", N5, Width - 2 * diaOfN2a, 75, bb, cc, 3, eShapeType.MI));
            RebarList.Add(new MIRebarRecord(5, 2, "", N5, Width - 2 * diaOfN2a, 75, bb, cc, 3, eShapeType.MI));


            #region 起步钢筋
            //if (true)
            //{

            //    RebarList.Add(new MHXRebarRecord(6, 1, "", eDB.DB32, false, 15 * 2, eShapeType.MHXe));
            //    RebarList.Add(new MHXRebarRecord(6, 2, "", eDB.DB32, false, 12 * 2, eShapeType.MHXe));
            //    RebarList.Add(new MHXRebarRecord(6, 3, "", eDB.DB32, true, 10 * 2, eShapeType.MHXi));
            //    RebarList.Add(new MHXRebarRecord(6, 4, "", eDB.DB32, true, 26, eShapeType.MHXi));
            //    RebarList.Add(new MHXRebarRecord(6, 5, "", eDB.DB32, false, 4 * 2, eShapeType.MHXe));
            //}
            //else
            //{
            //    // 未完成
            //    throw new NotImplementedException();
            //}
            //ColumnBase theColumn = MemberFactory.CreatMember(MemberFactory.FromFootingToColumn(_ePCType), SubType,19728);

            #endregion
        }



    }

}
